package com.yb0os1.mapper;

import com.yb0os1.annotation.AutoFill;
import com.yb0os1.entity.Setmeal;
import com.yb0os1.entity.SetmealDish;
import com.yb0os1.enumeration.OperationType;
import com.yb0os1.vo.DishItemVO;
import com.yb0os1.vo.SetmealVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealMapper {
    @Select("select * from setmeal where category_id=#{categoryId} and status=#{status}")
    List<Setmeal> list(Setmeal setmeal);

    @AutoFill(value=OperationType.INSERT)
    void insertSetmeal(Setmeal setmeal);




    @Select("select * from setmeal where id=#{id}")
    SetmealVO selectSetmeal(Long id);

    List<SetmealVO> select(String name, Long categoryId, Integer status);

    @AutoFill(value = OperationType.UPDATE)
    void update(Setmeal setmeal);

    @Select("SELECT setmeal_dish.* from setmeal LEFT JOIN setmeal_dish on setmeal_id=setmeal.id where setmeal.id = #{id}")
    List<SetmealDish> selectSetmealWithDishs(Long id);


    void deleteSetmeal(List<Long> ids);

    @Select("select * from setmeal_dish where setmeal_id = #{id}")
    List<DishItemVO> selectDishs(Long id);

    @Select("select count(*) from setmeal where status = #{status}")
    Integer selectSetmealStatus(Integer status);
}
